package com.fxd.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

    private DateUtil() {
    }

    private static final String yyyyMMdd = "yyyy-MM-dd";

    private static final String yyyyMM = "yyyy-MM";

    /**
     * 将日期对象转化为yyyy-MM-dd格式的字符串
     *
     * @param date
     * @return
     */
    public static String getDate2StrOfDay(Date date) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(yyyyMMdd);
        return simpleDateFormat.format(date);
    }

    /**
     * 将日期对象转化为yyyy-MM格式的字符串
     *
     * @param date
     * @return
     */
    public static String getDate2StrOfMonth(Date date) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(yyyyMM);
        return simpleDateFormat.format(date);
    }

}
